package com.example.myapplication3;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication3.bean.Student1;

import java.util.ArrayList;

public class Adapter extends RecyclerView.Adapter {
    private ArrayList<Student1.DataBean> list;
//    private ArrayList<Student2.DataBean> list2;
//    private ArrayList<Student3.DataBean> list3;
//    private ArrayList<Student4.DataBean> list4;
    private Context context;

    public Adapter(ArrayList<Student1.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.fu, viewGroup, false);
        ViewHolder holder = new ViewHolder(inflate);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
        ViewHolder holder1= (ViewHolder) viewHolder;
        Student1.DataBean bean1 = list.get(i);
//        Student2.DataBean bean2 = list2.get(i);
//        Student3.DataBean bean3 = list3.get(i);
//        Student4.DataBean bean4 = list4.get(i);

        holder1.t2.setText(bean1.getCity());

        holder1.t3.setText(bean1.getStation_code());
        holder1.t4.setText(bean1.getCity_code());
        holder1.t1.setText(bean1.getStation());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static
    class ViewHolder extends RecyclerView.ViewHolder {
        public View rootView;
        public TextView t1;
        public TextView t2;
        public TextView t3;
        public TextView t4;

        public ViewHolder(View rootView) {
            super(rootView);
            this.rootView = rootView;
            this.t1 = (TextView) rootView.findViewById(R.id.t1);
            this.t2 = (TextView) rootView.findViewById(R.id.t2);
            this.t3 = (TextView) rootView.findViewById(R.id.t3);
            this.t4 = (TextView) rootView.findViewById(R.id.t4);
        }

    }
}
